<template>
    <mi-form-page @submit="submit"
                  :loading="edit.loading"
                  v-model:show="edit.show"
                  title="商城配置"
    >
        <el-form :model="edit.info"
                 :rules="rules"
                 ref="formRef">

            <el-form-item prop="is_on_sign" label="开启签到功能">
                <mi-radio v-model="edit.info.value.is_on_sign" />
            </el-form-item>

            <el-form-item prop="is_on_coupon" label="开启优惠券功能">
                <mi-radio v-model="edit.info.value.is_on_coupon" />
            </el-form-item>

            <el-form-item prop="order_cancel_delay" label="未支付订单">
                <mi-input-number v-model="edit.info.value.order_cancel_delay" />
                <mi-form-aux>秒后，订单自动取消</mi-form-aux>
            </el-form-item>

            <el-form-item prop="order_receive_delay" label="已发货订单">
                <mi-input-number v-model="edit.info.value.order_receive_delay" />
                <mi-form-aux>秒后，订单自动确认收货</mi-form-aux>
            </el-form-item>

            <el-form-item prop="order_close_delay" label="已收货订单">
                <mi-input-number v-model="edit.info.value.order_close_delay" />
                <mi-form-aux>秒后，订单自动关闭</mi-form-aux>
            </el-form-item>

        </el-form>
    </mi-form-page>
</template>

<script setup lang="ts">
import {ref, onBeforeMount, inject, computed, watch} from "vue";
import {simpleGet} from "@/utils/request";
import {FormInstance} from "element-plus";
import Edit from "@/model/edit";

const url = '/site.siteConfig/edit'

const rules = {

}

const loading = ref(false)
const formRef = ref<FormInstance>()
const edit = inject('store', new Edit({}))
edit.info = {value:{}}

const submit = () => {
    edit.submit({
        formRef: formRef.value,
        url: url,
    })
}

watch(() => edit.show, (nv,ov) => {
    edit.init(async () => {
        let {info} = await simpleGet(url, {key:'store'})
        edit.info = info
    })
})


</script>

<style scoped>

</style>

